﻿function testEmpty(idField, errorstring){
	if(document.getElementById(idField).value.length == 0){
		warn(idField, errorstring);
	}else{
		cleanWarning(idField);
	}
}

function warn(idField, errorstring){
	document.getElementById(idField).style.border="solid 2px red";
	document.getElementById(idField).style.backgroundColor="#ff9999";
	if(document.getElementById(idField).parentNode.lastChild.nodeName != "H3"){
		error=document.createElement("h3");
		document.getElementById(idField).parentNode.appendChild(error);
		document.getElementById(idField).parentNode.lastChild.innerHTML=errorstring;
	}
}

function cleanWarning(idField){
	document.getElementById(idField).style.border="";
	document.getElementById(idField).style.backgroundColor="";
	if(document.getElementById(idField).parentNode.lastChild.nodeName == "H3")
		document.getElementById(idField).parentNode.removeChild(document.getElementById(idField).parentNode.lastChild);
}
